public class Test02 {
    public String name="admin";
    public String password="123456";
    public void login(String name,String password){
        if (!this.name.equals(name)){
            System.out.println("adminsion error");
            throw new UserNameException("your admin is wrong");

        }if (!this.password.equals(password)){
            System.out.println("password errow");
            throw new PasswordException("your password is wrong");
        }
    }

    public static void main(String[] args) {
        Test02 test02=new Test02();
        try{
            test02.login("adminsion","12312");
        }catch(UserNameException e){
            //捕捉到，抛出账户自定义异常
        }catch (PasswordException e){
            //抛出密码错误自定义异常
        }finally {
            //资源管理
        }
    }
}
